import { ref } from 'vue'
import { defineStore } from 'pinia'

export const useCustomerStore = defineStore('customer', () =>{
  const customer = ref({
    customerId: '',
    customerName: '',
    gender: '',
    email: '',
    phoneNumber: '',
  });

  // 用户模块 token setToken removeToken
  const token = ref('')

  const setToken = (newToken) => {
    token.value = newToken
  }

  const removeToken = () => {
    token.value = ''
  }

  //设置用户信息
  const setCustomerInfo = (customerInfo) => {
    customer.value = customerInfo;

  }

  return {customer,setCustomerInfo,token,setToken,removeToken}
},
{
  // 配置Pinia持久化
  unistorage: true, // 开启后对 state 的数据读写都将持久化
}
)
